//
//  FoodPracticeCell.m
//  FoodCorner
//
//  Created by Summer on 16/2/29.
//  Copyright © 2016年 zhangchao. All rights reserved.
//

#import "FoodPracticeCell.h"
#import "ImageArrayModel.h"
#import <SDAutoLayout/UIView+SDAutoLayout.h>
#import <SDWebImage/UIImageView+WebCache.h>
@interface FoodPracticeCell ()
@property (nonatomic,strong) UIImageView *imgView;
@property (nonatomic,strong) UILabel *subTitle;
@property (nonatomic,strong) UIView *lineView;
@end
@implementation FoodPracticeCell
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self addAllViews];
        
    }
    return self;
}
- (void)addAllViews
{
    CGFloat margin = 10;
    _imgView = [UIImageView new];
    _imgView.layer.masksToBounds = YES;
    _imgView.layer.cornerRadius = 80.0;
    [self.contentView addSubview:_imgView];
    _subTitle = [UILabel new];
    _subTitle.numberOfLines = 0;
    //_subTitle.backgroundColor = [UIColor redColor];
    _subTitle.textColor = [UIColor grayColor];
    _subTitle.font =[UIFont systemFontOfSize:14.0];
    [self.contentView addSubview:_subTitle];
    
    _lineView = [UIView new];
    _lineView.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:_lineView];
    
    self.imgView.sd_layout
    .leftSpaceToView(self.contentView,margin)
    .topSpaceToView(self.contentView,margin)
    .widthIs(160)
    .heightIs(160);
    
    self.subTitle.sd_layout
    .rightSpaceToView(self.contentView,margin)
    .leftSpaceToView (self.imgView,margin)
    .topSpaceToView (self.contentView,margin)
    .heightRatioToView(self.contentView,0.75);
    
    
    self.lineView.sd_layout
    .topSpaceToView(self.imgView,margin)
    .rightSpaceToView(self.contentView,0)
    .leftSpaceToView(self.contentView,0)
    .heightIs(1);
    
    [self setupAutoHeightWithBottomView:self.lineView bottomMargin:0];
    

}
- (void)setModel:(ImageArrayModel *)model
{
    _model = model;
    [self.imgView sd_setImageWithURL:[NSURL URLWithString:model.img] placeholderImage:[UIImage imageNamed:@"placeholder"]];
    self.subTitle.text = model.step;
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
